//
// Created by mio on 25-5-19.
//

#ifndef AUDIORENDER_H
#define AUDIORENDER_H



#include <QAudioSink>
#include <QAudioFormat>

#include "AV_Common.h"

class AudioRender
{
public:
    AudioRender();
    ~AudioRender();

    inline bool IsInit(){ return is_initail_; }

    //获取缓冲区pcm大小
    int AvailableBytes();
    bool InitAudio(int nChannels,int SampleRate,int nSampleSizeBits);
    //播放音频
    void Write(AVFramePtr frame);

private:
    bool is_initail_ = false;
    // int  nSampleSize_ = -1;
    int  sampleBits_  = -1;      // 保存位深，而不是旧 API 的 sampleSize
    int  volume_ = 50;
    //接入设备
    QAudioFormat  audioFmt_;
    QIODevice*    device_ = nullptr;
    QAudioSink*    audioSink_   = nullptr; // Qt6: 改成 QAudioSink
};



#endif //AUDIORENDER_H
